<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
  <meta charset="UTF-8">
  <title>资讯详情页</title>
  <meta name="page-view-size" content="1280*720">
  <link rel="stylesheet" href="../css/base.css">
  <link rel="stylesheet" href="../css/activeDetail.css">
  <script type="text/javascript" src="../lib/js/evm.js"></script>
  <script type="text/javascript" src="../lib/js/Evm_djyw.js"></script>
  <script type="text/javascript" src="../lib/js/key.js"></script>
  <script src="../lib/js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
  <script src="../lib/js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/api.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/public.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/video.js"></script>
  <script>
    marqueerun = false//在public.js后面赋值，可拦截跑马灯滚动

  </script>
  <style>
    .author {
      color: #EF5645;
    }
  </style>
</head>

<body>
  <div class="articleDetail-bg" id="articleDetailMain">

    <div id="articleDetailBody">
      <div class="title"></div>
      <!-- <div class="time"></div> -->
      <!-- <div class="author"></div> -->
      <div class="view"></div>
      <div class="likeNumber"></div>
      <div class="model" id="modelImg">
        <img class="imgs" src="" alt="">
        <div class="alearts">点击可全屏并切换</div>
        <!-- <div class='confirm'>确定</div> -->
      </div>
      <div class="model" id="detailContain">
        <div id="introduction">活动介绍：</div>
        <div class="container" id="detail">
          <div class="content" id="content">
          </div>
        </div>
        <div class="join" id="join">报名</div>
      </div>
      <div class="model" id="like">
        点赞
      </div>
      <!-- <div class="model" id='collection'>
              收藏
            </div> -->
      <div class="share">
        <img src="" alt="">
        扫码分享
      </div>
      <div class="detailMsg">
        <div class="detailRow">
          <div class="detailName">组 织 人：</div>
          <div class="detailTxt  contacter"></div>
        </div>
        <!-- <div class="detailRow">
                  <div class="detailName">联系方式：</div>
                  <div class="detailTxt phone"></div>
                </div> -->
        <div class="detailRow">
          <div class="detailName">报名人数：</div>
          <div class="detailTxt num"></div>
        </div>
        <div class="detailRow">
          <div class="detailName">开始时间：</div>
          <div class="detailTxt startTime">

          </div>
        </div>
        <div class="detailRow">
          <div class="detailName">结束时间：</div>
          <div class="detailTxt endTime">

          </div>
        </div>
        <div class="detailRow">
          <div class="detailName">活动地址：</div>
          <div class="detailTxt address">

          </div>
        </div>
      </div>
    </div>
</body>
<script>
  var modelIndex = {
    disUser: true,
    //isVideo: true,
    index: 1, //初始位置
    listName: 'model', //模块名称
    containerId: 'articleDetailBody', //包含模块的标签id
    thisContain: 'detail', //翻滚外容器
    thisDetail: 'content', //翻滚内容
  }

  var articleRun;
  var photos;
  function direOpt(index, directive) {
    if (directive == "up") {//上
      if (index == 1) {//文章翻滚
        TV.articleMove(directive, modelIndex.thisContain, modelIndex.thisDetail);
      } else if (index == 2 || index == 3) {
        index = 0;
      }
    } else if (directive == "down") {//下
      if (index == 1) {//文章翻滚
        TV.articleMove(directive, modelIndex.thisContain, modelIndex.thisDetail);
      } else if (index == 0) {
        index = 2;
      }
    } else if (directive == 'forwards') {
      if (index == 0) {
        index = 1
      } else if (index == 1) {
        index++
      } else if (index == 2) {
        index = 1
      }
      clearInterval(articleRun);
    } else if (directive == 'backwards') {
      if (index == 1) {
        index = 0
      } else if (index == 2 || index == 3) {
        index--;
      }
      clearInterval(articleRun);
    }
    return index;
  }

  function getMessage() {
    var isvolunteer = TV.GetParam('active')
    console.log(isvolunteer)
    var access_token = $.cookie('TV_CST_TOKEN');
    var param = {
      // id: TV.GetParam('id'),
      id: TV.GetParam("id") ? TV.GetParam("id") : 284,
      access_token: access_token,
      // area_id: $.cookie('TV_CST_AREA')
    }
    GetDatas('getActivity', param, function (err, res) {
      var mess = res.data;
      photos = mess.images.length == 0 ? mess.img : mess.images;
      console.log(photos)
      console.log(mess)
      $('.content').html(mess.content);
      $('.title').html(mess.title)
      $('.time').html(mess.format_start_time)
      $('.author').html(mess.group_name)
      $('.view').html(mess.click_count)
      $('.likeNumber').html(mess.likes)
      $('#collection').remove()
      $('.contacter').html(mess.contacter)
      $('.num').html(mess.bm_count)
      $('.startTime').html(mess.format_start_time)
      $('.endTime').html(mess.format_end_time)
      $('.phone').html(mess.phone)
      $('.address').html(mess.address)
      if (mess.images) {
        $('.imgs').attr('src', API_URL['imgURL'] + mess.images);
      } else {
        $('.imgs').attr('src', '../images/base.png');
        $('.alearts').html('暂无详情图片')
      }
      if (mess.status == 2) {
        $('.join').html('已结束')
        $('#join').addClass('unable');
      }
      if (mess.is_like == 1) {  //这个字段有问题，接口中没有给出
        $('#like').css('background-image', 'url(../images/like-2.png)')
      }
      if (isvolunteer == "active") {
        var surl = API_URL.loginURL + "home/index/qrcode?url=" + encodeURIComponent(
          API_URL.WXActivityUrlDetail + '/' + TV.GetParam('id'));
      } else {
        var surl = API_URL.loginURL + "home/index/qrcode?url=" + encodeURIComponent(
          API_URL.WXServeUrlDetail + '/' + TV.GetParam('id'))
      }
      $('.share img').attr('src', surl)
    })
  }
  getMessage();

  function direEnter(index) {
    if (index == 0 && photos && photos.length) {
      window.location.href = './A_DetailPhoto.html?id=' + TV.GetParam('id') + "&type=activity";
    } else if (index == 1) {
      var access_token = $.cookie('TV_CST_TOKEN');
      var param = {
        id: TV.GetParam('id'),
        access_token: access_token,
      }
      GetDatas('join', param, function (err, res) {
        console.log(res)
        if (res.code == 0) {
          TV.PromptMsg('报名成功')
          $(".cur-number").eq(index).html(res.data.likes);
          // $('#like').css('background-image','url(../images/like-2.png)')
        } else if (res.code == 10009) {//登录已过期

          TV.userLogin();
          direEnter(index);
          // alert('111')
        } else if (res.code == 401) {//未登录
          window.location.href = './login.html';
        } else {
          var message = res.message
          TV.PromptMsg(message)
        }
      })
    } else if (index == 2) {
      var access_token = $.cookie('TV_CST_TOKEN');
      console.log(access_token)
      var param = {
        id: TV.GetParam('id'),
        access_token: access_token,
      }
      GetDatas('activityLike', param, function (err, res) {
        console.log(res)
        if (res.code == 0) {
          TV.PromptMsg('点赞成功')
          $(".likeNumber").html(res.data.likes);
          $('#like').css('background-image', 'url(../images/like-2.png)')
        } else if (res.code == 10009) {

          TV.userLogin();
          direEnter(index);
          // alert('111')
        } else {
          var message = res.message
          TV.PromptMsg(message)
        }
      })
    }
  }
</script>
<script type="text/javascript" src="../js/index.js"></script>

</html>